const { Model , DataTypes } = require('sequelize');

const sequelize = require('../db/conn.js');

const Student = require( './Student' );
const Course = require( './Course' );

class Score extends Model {
}

const attributes = {
    studentId: {
        type: DataTypes.INTEGER,
        field: 'student_id',
        references: {
            model: Student ,
            key: 'id'
        }
    },
    courseId: {
        type: DataTypes.INTEGER,
        field: 'course_id' ,
        references: {
            model: Course ,
            key: 'id'
        }
    },
    chooseTime: {
        type: DataTypes.DATE,
        field: 'choose_time'
    },
    examTime: {
        type: DataTypes.DATE,
        field: 'exam_time'
    },
    examScore: {
        type: DataTypes.FLOAT,
        field: 'exam_score'
    }
}

const options = {
    tableName: 't_scores',
    sequelize: sequelize ,
    timestamps: false
}

Score.init( attributes , options );

module.exports = Score ;